Schedules


Overview

Schedules are a type of loop specific to Pog that executes code blocks at regular timed intervals. Schedules can only be used in task functions. See Multitasking for more details of tasks.

Schedules are useful when you wish to execute code at regular intervals, for example you might wish to check every second to see if a spaceship has reached a waypoint.

 

Defining a Schedule

A schedule takes the form:

// Schedule block start
schedule
{
	// This code block executes once per second.
	every 1 :
	{
		Debug.PrintString( "Hello!\n" );
	}
}

The schedule keyword defines the start of the schedule, while the every keyword defines the time interval in seconds that the schedule waits before executing the code block. You can use non-integer values, so an interval of 0.1 would be 1/10th of a second.

You can run multiple every blocks in the same schedule, with different time intervals, e.g.

schedule
{
	every 1 :
	{
		Debug.PrintString( "Hello\n" );
	}	
	every 10 :
	{
		Debug.PrintString( "World!\n" );
	}
}

 

Exiting a Schedule
To exit a schedule use break as in switch statements and for / do / while loops. e.g.

schedule
{
	every 1 :
	{
		Debug.PrintString( "Hello\n" );
		if ( count == 10 ) break;
	}
}

You can also return from within a schedule.